package com.pur.zsms.lockmanage.dao.impl;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Query;

import net.sf.json.JSONObject;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Repository;

import com.pur.zsms.common.dao.GenericDao;
import com.pur.zsms.common.dao.JpaTemplate;
import com.pur.zsms.common.exception.GenericException;
import com.pur.zsms.common.support.PageController;
import com.pur.zsms.common.support.PaginationSupport;
import com.pur.zsms.foodmanage.food.dao.IFoodDao;
import com.pur.zsms.foodmanage.food.po.FoodMaterPo;
import com.pur.zsms.foodmanage.food.po.FoodPo;
import com.pur.zsms.foodmanage.food.vo.FoodMaterVo;
import com.pur.zsms.foodmanage.food.vo.FoodVo;
import com.pur.zsms.lockmanage.dao.ILockTransDao;
import com.pur.zsms.lockmanage.po.LockTransPo;
import com.pur.zsms.matermanage.mater.po.MaterLevelPo;
import com.pur.zsms.pmsnmanage.menu.po.MenuPo;
import com.pur.zsms.pmsnmanage.role.vo.RoleVo;
import com.pur.zsms.pmsnmanage.user.dao.IUserDao;
import com.pur.zsms.pmsnmanage.user.po.UserPo;
import com.pur.zsms.pmsnmanage.user.po.UserRolePo;
import com.pur.zsms.pmsnmanage.user.vo.UserVo;
import com.pur.zsms.supplier.po.SupplierPo;
import com.pur.zsms.systemsetting.datadictionary.po.CodeType;

@Repository("lockTransDao")
public class LockTransDaoImpl extends GenericDao implements ILockTransDao {

	public List<LockTransPo> getLockTransPo(String method, int supId) throws GenericException {
		JpaTemplate template = this.getTemplate();
		StringBuffer ql = new StringBuffer();
		ql.append(" select o from LockTransPo o where o.lockName = '" + method + "' and o.supId = '" + supId + "'");
		List<LockTransPo> list = template.find(ql.toString(), null);
		return list;
	}

	// 判断客户锁是否存在
	public List<LockTransPo> getLockTransPoForCust(String method, long custId) throws GenericException {
		JpaTemplate template = this.getTemplate();
		StringBuffer ql = new StringBuffer();
		ql.append(" select o from LockTransPo o where o.lockName = '" + method + "' and custId ='" + custId + "'");
		List<LockTransPo> list = template.find(ql.toString(), null);
		return list;
	}

	public void updateSupplier(LockTransPo c) throws GenericException {
		this.merge(c);
	}

	public void addSupplier(LockTransPo c) throws GenericException {
		this.persist(c);
	}

}
